package com.htgd.gardenexpo.controller;


import com.htgd.gardenexpo.entity.CommonResult;
import com.htgd.gardenexpo.entity.GeConFoodRule;
import com.htgd.gardenexpo.entity.GeConPortraitRules;
import com.htgd.gardenexpo.service.IGeConFoodRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 美食榜规则 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-11
 */
@RestController
@RequestMapping("/api/foodRule")
@Api(tags = "美食榜规则")
public class GeConFoodRuleController {

    @Autowired
    private IGeConFoodRuleService geConFoodRuleService;

    @PostMapping(value = "/edit")
    @ApiOperation("编辑")
    public CommonResult edit(@RequestBody GeConFoodRule geConFoodRule) {
        if(geConFoodRule.getStatus()==1){
            if(geConFoodRule.getCollect()+geConFoodRule.getHit()!=100){
                return CommonResult.error("比例之和未达到100");
            }
        }
        geConFoodRule.setId("1");
        geConFoodRuleService.updateById(geConFoodRule);
        return CommonResult.success("修改成功");
    }

    @GetMapping(value = "/details")
    @ApiOperation("详情")
    public CommonResult<GeConFoodRule> details() {
        GeConFoodRule geConFoodRule = geConFoodRuleService.getById("1");
        return CommonResult.success("查询成功",geConFoodRule);
    }

}
